package com.anan.config;

import com.anan.Interceptor.ProjectInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author anan
 * @date 2023/03/17/17:11
 **/

@Configuration
public class GlobalWebAppConfig implements WebMvcConfigurer {
    @Resource
    private ProjectInterceptor projectInterceptor;

    /**
     * 添加拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("拦截器开启。。。");
        registry.addInterceptor(projectInterceptor).addPathPatterns("/**");
    }

    //设置拦截请求filter拦截路径
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/starts/**").addResourceLocations("/dist/");
//        registry.addResourceHandler("/starts/**").addResourceLocations("/view/");
    }
}
